package com.medata.service.impl;

import com.medata.dataObject.Advice;
import com.medata.repository.AdviceRepository;
import com.medata.service.AdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author ：zb
 * @date ：Created in 2019/8/7 0007 13:59
 * @description：
 */
@Service
public class AdviceServiceImpl implements AdviceService {
    @Autowired
    private AdviceRepository repository;
    @Override
    public Page<Advice> findByUserName(String name, Pageable pageable) {
        return repository.findByUserName(name,pageable);
    }

    @Override
    public List<Advice> findAll() {
        return repository.findAll();
    }

    @Override
    public Page<Advice> findAll(Pageable pageable) {
        return repository.findAll(pageable);
    }

    @Override
    @Transactional
    public void deleteAll() {
        repository.deleteAll();
    }

    @Override
    @Transactional
    public void delete(Integer id) {
        repository.deleteById(id);
    }
}
